package logic

import (
	"sync"

	"gitee.com/liuxuezhan/ar-platform/assets-rpc/internal/config"

	"github.com/redis/go-redis/v9"
)

var redisCliOnce sync.Once
var redisClient *redis.Client

func GetRedisClient(c config.RedisConf) *redis.Client {
	if redisClient == nil {
		redisCliOnce.Do(func() {
			redisClient = redis.NewClient(&redis.Options{
				Addr:     c.Address,
				Password: c.Password,
				DB:       c.DB,
			})
		})
	}
	return redisClient
}
